package com.antdesignbackend.backend.service.impl;

import com.antdesignbackend.backend.entity.Button;
import com.antdesignbackend.backend.entity.RoleButton;
import com.antdesignbackend.backend.mapper.ButtonMapper;
import com.antdesignbackend.backend.mapper.RoleButtonMapper;
import com.antdesignbackend.backend.service.ButtonService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class ButtonServiceImpl extends ServiceImpl<ButtonMapper, Button> implements ButtonService {
    @Autowired
    ButtonMapper buttonMapper;
    @Autowired
    RoleButtonMapper roleButtonMapper;

    @Override
    @Transactional(rollbackFor = {RuntimeException.class, Error.class})
    public void add(Button button, RoleButton roleButton) {
        buttonMapper.insert(button);
        roleButtonMapper.insert(roleButton);
    }
}
